
//#include "LWP.h"
//#include "impl.h"
#include "LWP/UserAgent.h"
#include "HTTP.h"

#include <iostream>
#include <string>

using namespace std;

using namespace HTTP;
using namespace LWP;

void test()
{

	HttpHeader header;
//	header.add_header("Connection", "keep-alive");
//	header.add_header("Keep-Alive", "300");

	HttpForm form;
	form.add_data("user", "cin");
	form.add_data("title", "");
	form.add_data("title2", "");
	form.add_data("title3", "");
	form.add_data("day", "1");
	form.add_data("day2", "9999");
	form.add_data("flag", "1");


	UserAgent ua;
//	ua.agent("Mozilla/5.0 (X11; U; Linux i686; zh-CN; rv:1.8.1) Gecko/20061010 Firefox/2.0");
//	ua.agent("LWP");
	ResponseObject resp = ua.get("www.google.com", header);
//	ResponseObject resp = ua.get("www.sina.com.cn", header);
//	ResponseObject resp = ua.post("bbs.nju.edu.cn/bbsfind", header);
//	cout<<resp.get_data()<<'x'<<endl;
	cout<<resp.get_html()<<endl;
//	resp.get_html();
	

/*
	cout<<"################################"<<endl;
	LWP::UserAgent ua;
	ua.agent("Mozilla/5.0 (X11; U; Linux i686; zh-CN; rv:1.8.1) Gecko/20061010 Firefox/2.0");
	ResponseObject resp = ua.post("bbs.nju.edu.cn/bbsfind", header, form);
	cout<<"################################"<<endl;
//	cout<<resp.is_success()<<endl;
//	cout<<resp.status_line()<<endl;
//	cout<<resp.content_type()<<endl;
//	cout<<"header: "<<resp.header_string()<<endl;
	cout<<"################################"<<endl;
//	cout<<"length: "<<resp.content().length()<<endl;
//	cout<<"content: "<<resp.content()<<endl;
	cout<<"data: \n"<<resp.get_data()<<endl;
	cout<<"################################"<<endl;
*/
	
}

int main()
{
	UserAgent ua;
	cout<<ua.get("www.google.com").content().length()<<endl;
	cout<<ua.get("www.sina.com.cn").content().length()<<endl;
	cout<<ua.get("bbs.plu.com.cn").header_string()<<endl;
}

